import 'package:app/pages/login_modules/register_module/register_controller.dart';
import 'package:app/pages/login_modules/register_module/register_getcode_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import '../../../utils/phone_inputformatter.dart';
import '../../../utils/hexcolor.dart';

class RegisterView extends GetView{


  RegisterController controller = Get.put(RegisterController());

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        // leading: new IconButton(
        //   icon: Image.asset(A.assets_arrback_icon),
        //   onPressed: () => {
        //     Navigator.of(context).pop('刷新')
        //   },
        // ),
      ),
      body: GetBuilder<RegisterController>(builder: (_){
        return Column(
          crossAxisAlignment:CrossAxisAlignment.start,
          children: [
            Container(
              margin: EdgeInsets.only(top: 20,left: 20),
              child: Text('注册'.tr,style: TextStyle(fontSize: 24,fontWeight: FontWeight.w500),),
            ),
            Container(
              margin: EdgeInsets.only(top: 5,left: 20),
              child: Text('未注册的手机号验证后自动注册'.tr,style: TextStyle(fontSize: 12,color: HexColor('#999999')),),
            ),


            Container(
              margin: EdgeInsets.only(left: 20,top: 50),
              child: TextField(

                onChanged: (text){
                  controller.strMobile = text;
                  // String phoneNo = TextUtil.formatSpace4("${text}"); // 1584 5678 910
                  controller.tf.text = text;
                  controller.tf.selection =
                      TextSelection.fromPosition(
                          TextPosition(offset: controller.tf.text.length));
                },


                autofocus: true,
                keyboardType: TextInputType.phone,
                controller: controller.tf,
                inputFormatters: <TextInputFormatter>[
                  LengthLimitingTextInputFormatter(13),//限制长度
                  phoneInputFormatter(),

                ],
                style: TextStyle(
                    fontSize: 24,
                    color: HexColor('333333')
                ),
                decoration: InputDecoration(
                  border: InputBorder.none,
                  hintStyle: TextStyle(fontSize: 24,color: HexColor('#CCCCCC')),
                  hintText: '请输入手机号码'.tr,
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 50,right: 25,left: 25),
              width: Get.width,
              height: 45,
              child: MaterialButton(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(22),
                ),
                color:Theme.of(context).primaryColor,
                onPressed: ()async{
                 controller.tapClickGetCode();

                },
                child: Text('获取验证码'.tr,style: TextStyle(color: Colors.white),),
              ),
            ),
          ],
        );
      }),
    );
  }

}